#include <WIFI.hpp>
#include <Ticker.h> //调度器定时
#include <PubSubClient.h>//client
#define PIN_LED LED_BUILTIN //测试的LED端口 
 
 WIFI wifi;
bool isConnent = false;//是否连接了

void setup() {
 pinMode(PIN_LED, OUTPUT);
  //wifi.removeCache();//移除存储的信息
  wifi.setCallBack(&callback);
  //wifi.Start("app_001", "12345678");
  wifi.Start();
}


void callback() {
  //连接了完成
  Serial.println("连接成功!");

  isConnent = true;

}

void loop() {
    wifi.loop();
  if (isConnent) {
    //连接成功
    digitalWrite(PIN_LED, 0);
    //断开连接
    if (WiFi.status() != WL_CONNECTED) {
        digitalWrite(PIN_LED, 0);
      delay(2000);
      digitalWrite(PIN_LED, 1);
      delay(2000);
    } 

  } else {
    //未连接
    digitalWrite(PIN_LED, 0);
    delay(500);
    digitalWrite(PIN_LED, 1);
    delay(500);
  }
}


 